View Javadoc

1   // Interface.java, created Fri Apr  5 18:36:41 2002 by joewhaley
2   // Copyright (C) 2001-3 John Whaley <jwhaley@alum.mit.edu>
3   // Licensed under the terms of the GNU LGPL; see COPYING for details.
4   package joeq.ClassLib.sun142_linux;
5   
6   import java.util.Collections;
7   import java.util.Iterator;
8   import joeq.Class.PrimordialClassLoader;
9   import joeq.Class.jq_Class;
10  import joeq.ClassLib.ClassLibInterface;
11  import joeq.Runtime.ObjectTraverser;
12  import jwutil.collections.AppendIterator;
13  
14  /*
15   * @author  John Whaley <jwhaley@alum.mit.edu>
16   * @version $Id: Interface.java 1941 2004-09-30 03:37:06Z joewhaley $
17   */
18  public class Interface extends joeq.ClassLib.sun14_linux.Interface {
19  
20      /*** Creates new Interface */
21      public Interface() {}
22  
23      public Iterator getImplementationClassDescs(joeq.UTF.Utf8 desc) {
24          if (ClassLibInterface.USE_JOEQ_CLASSLIB && desc.toString().startsWith("Ljava/")) {
25              joeq.UTF.Utf8 u = joeq.UTF.Utf8.get("Ljoeq/ClassLib/sun142_linux/"+desc.toString().substring(1));
26              return new AppendIterator(super.getImplementationClassDescs(desc),
27                                        Collections.singleton(u).iterator());
28          }
29          return super.getImplementationClassDescs(desc);
30      }
31      
32      public ObjectTraverser getObjectTraverser() {
33          return sun142_linuxObjectTraverser.INSTANCE;
34      }
35      
36      public static class sun142_linuxObjectTraverser extends sun14_linuxObjectTraverser {
37          public static sun142_linuxObjectTraverser INSTANCE = new sun142_linuxObjectTraverser();
38          protected sun142_linuxObjectTraverser() {}
39          public void initialize() {
40              super.initialize();
41              
42              jq_Class k;
43              k = (jq_Class) PrimordialClassLoader.loader.getOrCreateBSType("Ljoeq/ClassLib/Common/java/util/zip/DeflaterHuffman;");
44              k.load();
45              
46              // used during bootstrapping.
47              k = (jq_Class) PrimordialClassLoader.loader.getOrCreateBSType("Ljava/io/ObjectInputStream$GetFieldImpl;");
48              k.load();
49              
50              // 1.4.2 adds caches to UnixFileSystem, which we should not reflectively inspect.
51              k = (jq_Class) PrimordialClassLoader.loader.getOrCreateBSType("Ljava/io/UnixFileSystem;");
52              nullInstanceFields.add(k.getOrCreateInstanceField("cache", "Ljava/io/ExpiringCache;"));
53              nullInstanceFields.add(k.getOrCreateInstanceField("javaHomePrefixCache", "Ljava/io/ExpiringCache;"));
54              
55              // reference these now, so that they are not added during bootimage write.
56              k = (jq_Class) PrimordialClassLoader.loader.getOrCreateBSType("Ljava/io/ExpiringCache;");
57              k.load();
58              k = (jq_Class) PrimordialClassLoader.loader.getOrCreateBSType("Ljava/io/ExpiringCache$Entry;");
59          }
60      }
61  }